package com.jzhao.jpre.model.dao;

import javax.sql.DataSource;

import org.springframework.jdbc.core.JdbcTemplate;

import com.jzhao.jpre.base.StringPublicDeal;
import com.jzhao.jpre.model.PmsPosUse;


public class PmsPosUseDao 
{
	protected JdbcTemplate jdbcTemplate;
	protected StringPublicDeal strPubDeal;

	public void setDataSource(DataSource dataSource) 
	{
		jdbcTemplate = new JdbcTemplate(dataSource);
	}

	public void setStrPubDeal(StringPublicDeal strPubDeal) 
	{
		this.strPubDeal = strPubDeal;
	}


	public void insertPara(PmsPosUse pmsPosUse,int x,int y,String z)
	{
		/*int iSeqId = 0;
		String seqSql = "SELECT SEQ_PMS_POS_USE.nextval FROM dual";
		iSeqId = jdbcTemplate.queryForInt(seqSql);
		
		String sql = "INSERT INTO PMS_POS_USE" +
				"(ID, OPERATETIME, POSSN, OPERATOR," +
				" BUSINESSFLAG,CAUSE,POSSERIALNO) "
				+ " VALUES"
				+ "(?,new date(),?,?,?,?,?)";
		
		
	
		Object[] para = new Object[]{
				new Integer(iSeqId),
				pmsPosUse.getPossn(),
				new Integer(x),
				new Integer(y),
				z,
				pmsPosUse.getPosserialno()
						
		};		
		jdbcTemplate.update(sql, para);ORACLE*/
		
		String sql = "INSERT INTO PMS_POS_USE"
			+ "(OPERATETIME, POSSN, OPERATOR,"
			+ " BUSINESSFLAG,CAUSE,POSSERIALNO) " + " VALUES"
			+ "(now(),?,?,?,?,?)";
		Object[] para = new Object[]{
				pmsPosUse.getPossn(),
				new Integer(x),
				new Integer(y),
				z,
				pmsPosUse.getPosserialno()
						
		};		
		jdbcTemplate.update(sql, para);//MYSQL

	}
	
	public long getserno()
	{
		String seqSql = "SELECT SEQ_PMS_POS_USE.nextval FROM dual";
		return jdbcTemplate.queryForLong(seqSql);
	}
	
}